"""
 -*- coding: utf-8-*-
 @File: record_error.py
 @Author: chen
 @time: 2023/10/22/ 20:56
"""
from hogwartsHomework.homework_api_auto.utils.util_log import logger


def record_error(func):
    def _inner(*args, **kwargs):
        try:
            res = func(*args, **kwargs)
            # logger.info(res)
            if res.json()["errcode"] == 0:
                logger.info("接口请求--->成功")
            else:
                logger.warning("接口请求--->异常")
            return res
        except Exception as e:
            logger.error("接口请求--->异常")
            logger.error(f"异常信息：{e}")
            raise

    return _inner
